package recycle.common;

import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.ext.web.RoutingContext;

public class ResponseHandler {
    public static <T> Handler<AsyncResult<T>> handle(RoutingContext ctx) {
        return ar -> {
            if (ar.succeeded()) {
                ctx.json(Result.ok(ar.result()));
            } else {
                ctx.fail(ar.cause());
            }
        };
    }
}